<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>重置密码</title>
    <link rel="stylesheet" href="/assets/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/assets/css/personal/basiclnformation.css">
</head>

<body>
    <div class="layui-card">
        <div class="layui-card-header">修改密码</div>
        <div class="layui-card-body">
            <form class="layui-form" lay-filter="form-info">               
                <div class="layui-form-item">
                    <label class="layui-form-label">原密码</label>
                    <div class="layui-input-inline">
                        <input type="password" name="oldPwd" required lay-verify="required|pass" placeholder="请输入原密码"
                            autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">新密码</label>
                    <div class="layui-input-inline">
                        <input type="password" name="newPwd" required lay-verify="required|pass" placeholder="请输入新密码"
                            autocomplete="off" class="layui-input" id="pass">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">确认新密码</label>
                    <div class="layui-input-inline">
                        <input type="password" name="newPwd" required lay-verify="required|pwd" placeholder="确认新密码"
                            autocomplete="off" class="layui-input">
                    </div>
                </div>


                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="formDemo" id="submit_bnt">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary" id="reset">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <script src="/assets/lib/layui/layui.all.js"></script>
    <script src="/assets/lib/jquery.js"></script>
    <script src="/assets/js/baseApi.js"></script>
    <script>
        $(function () {
            const { form, layer } = layui;
            //验证表单数据 
            form.verify({
                pass: [
                    /^[\S]{6,12}$/
                    , '密码必须6到12位，且不能出现空格'
                ], pwd(value) {
                    if ($("#pass").val() !== value) return '密码不一致!'
                }
            })
            //提交密码重置
            $("#submit_bnt").on('click', function (e) {
                const data = form.val('form-info')
                e.preventDefault();
                console.log(data);
                $.ajax({
                    type: 'post',
                    url: '/my/updatepwd',
                    data,
                    success(res){                      
                        layer.msg(res.message)                        
                    }
                })
            })


        })
    </script>
</body>

</html>